From 95fe89367e89045575c246a7edf78b51ddfe6a0e Mon Sep 17 00:00:00 2001 From: Keir Fraser Date: Wed, 19 Aug 2009 12:58:15 +0100 Subject: [PATCH] x86: Fix max_gsi calculation on systems with discontiguous GSI space. From: Steven Smith Signed-off-by: Keir Fraser --- xen/arch/x86/io_apic.c | 5 +++++ xen/arch/x86/mpparse.c | 13 +++++++++++++ 2 files changed, 18 insertions(+) diff --git a/xen/arch/x86/io_apic.c b/xen/arch/x86/io_apic.c index 61ff2480e2..917e4dd9b0 100644 --- a/xen/arch/x86/io_apic.c +++ b/xen/arch/x86/io_apic.c @@ -2349,6 +2349,8 @@ void dump_ioapic_irq_info(void) } } +unsigned highest_gsi(void); + void __init init_ioapic_mappings(void) { unsigned long ioapic_phys; @@ -2390,6 +2392,9 @@ void __init init_ioapic_mappings(void) nr_irqs_gsi += nr_ioapic_registers[i]; } } + + nr_irqs_gsi = max(nr_irqs, highest_gsi()); + if ( !smp_found_config || skip_ioapic_setup || nr_irqs_gsi < 16 ) nr_irqs_gsi = 16; else if ( nr_irqs_gsi > MAX_GSI_IRQS) diff --git a/xen/arch/x86/mpparse.c b/xen/arch/x86/mpparse.c index 5f2be943e2..fcbb1a1968 100644 --- a/xen/arch/x86/mpparse.c +++ b/xen/arch/x86/mpparse.c @@ -945,6 +945,19 @@ void __init mp_register_ioapic ( return; } +unsigned highest_gsi(void) +{ + unsigned x; + unsigned res; + + res = 0; + for (x = 0; x < nr_ioapics; x++) { + if (res < mp_ioapic_routing[x].gsi_end) + res = mp_ioapic_routing[x].gsi_end; + } + return res; +} + void __init mp_override_legacy_irq ( u8 bus_irq, -- 2.30.2